package stdio.costa.moca.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import stdio.costa.UuidPersistentable;
import stdio.costa.moca.pdf.PdfGeneratable;

@Entity
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Img extends UuidPersistentable implements Serializable, PdfGeneratable {

	private static final long serialVersionUID = -4942309356539803380L;

	@Lob
	@XmlTransient
	private byte[] data;
	
	public Img(){
	}

	public Img(byte[] data) {
		this.data = data;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	@Override
	public boolean isReadyForPdfGeneration() {
		return data != null && data.length > 0;
	}
}
